﻿using Aliphant.Common.Managers;
using Aliphant.Mvvm.XEvent.Ioc;
using Aliphant.Mvvm.XEvent.UI;

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace Aliphant.UI.Windows
{
    public class UIWindow : UIWindowBase
    {
        public UIWindow()
        {
            CommandBindings.Add(new CommandBinding(GlobalProperty.TopWindowCommand, TopWindow));
            CommandBindings.Add(new CommandBinding(GlobalProperty.HomePageCommand, HomePage));
            GlobalProperty.SetThemeVisibleEvent += GlobalProperty_SetThemeVisibleEvent;

            GlobalProperty_SetThemeVisibleEvent(ConfigManager.Instance.Settings.ThemeVisible);
        }

        private void GlobalProperty_SetThemeVisibleEvent(bool obj)
        {
            ThemeVisible = obj ? Visibility.Visible : Visibility.Collapsed;
        }

        private bool isTop;
        private void TopWindow(object sender, ExecutedRoutedEventArgs e)
        {
            isTop = !isTop;
            this.Topmost = isTop;
        }


        private void HomePage(object sender, ExecutedRoutedEventArgs e)
        {
            UIContainerLocator.Container.NavigateTo("main", "homePage");
            Title = "XDeskTool";
            GlobalProperty.Navigated("");
        }

        private Visibility _themeVisible;
        public Visibility ThemeVisible { get => _themeVisible; set => SetProperty(ref _themeVisible, value); }
    }
}
